package org.example.compent;

import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.annotation.LiteflowMethod;
import com.yomahub.liteflow.core.NodeComponent;
import com.yomahub.liteflow.enums.LiteFlowMethodEnum;
import com.yomahub.liteflow.enums.NodeTypeEnum;
import com.yomahub.liteflow.slot.DefaultContext;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@LiteflowComponent("o")
public class OCmp {

    @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS_FOR, nodeType = NodeTypeEnum.FOR)
    public int processFor(NodeComponent component) throws Exception {
        DefaultContext contextBean = component.getContextBean(DefaultContext.class);
        int count = contextBean.getData("count");
        return count;
    }

    @LiteflowMethod(value = LiteFlowMethodEnum.IS_ACCESS, nodeType = NodeTypeEnum.FOR)
    public boolean isAccess(NodeComponent component){
        log.info("-------------O结点已执行------------");
        return true;
    }

    @LiteflowMethod(value = LiteFlowMethodEnum.BEFORE_PROCESS, nodeType = NodeTypeEnum.FOR)
    public void before(NodeComponent component){
        log.info("-------------O结点执行前------------");
    }

}
